const chartMedia = document.getElementById('media');
const pieChart = echarts.init(chartMedia);




const initMedia = pieData => {
    // option = {
    pieChart.setOption({
        tooltip: {
            trigger: 'item',
            // formatter:(params) => {
            //     let str = parmas.marker.replace('border-radius:10px;','').replace(/4px|10px/g,'5px')
            //     return `${str} ${params.data.name}:${parmas.data.percentage}%`
            // }
        },
        legend: {
            top: 'center',
                orient: 'vertical',
                    right: '0',
                        itemWidth: 10,
                            itemHeight: 10,
                                textStyle: {
                color: '#fff'
            },
            itemStyle: {
                borderWidth: 0
            }
        },
        series: [
            {
                name: '访问来源',
                type: 'pie',
                radius: ['40%', '70%'],
                avoidLabelOverlap: false,
                label: {
                    show: false,
                    // position: 'center',
                },
                emphasis: {
                    scale: false,
                    focus: 'series'
                },
                itemStyle: {
                    borderWidth: 1,
                    borderColor: '#fff'
                },
                labelLine: {
                    show: false
                },
                data: pieData
            }
        ]
    })
       
    // };
}

$.ajax({
    type: 'post',
    url: url + '/api/data-visualization/analysis/statistic/media/source',
    data: {
        beginDate: beginDate,
        endDate: endDate,
        keyword: '',
    },
    success(res) {
        if (res.code == 200) {
            // initWordCloud(res.data)
            console.log(res.data);
            initMedia(res.data)
        }
        // <div class="swiper-slide">Slide 1</div>
    },
    error(err) {
        console.log(err);
    }
})

// option && pieChart.setOption(option);